﻿<?php
header("Content-Type: text/html;charset=utf-8"); 
require_once '../model/PdoMySQL.class.php';
require_once '../model/config.php';
if ($_SERVER["REQUEST_METHOD"] == "POST"){
	create();
}
function create(){
	$id=$_POST["id"];
	$username=$_POST["username"];
	$password=base64_encode($_POST["password"]);
	$usertype=$_POST["usertype"];
	$email=$_POST["email"];
	$mobilephone=$_POST["mobilephone"];
	if (!isset($_POST["id"])||empty($_POST["id"])
		||!isset($_POST["username"]) || empty($_POST["username"])
		|| !isset($_POST["password"]) || empty($_POST["password"])
		|| !isset($_POST["usertype"]) || empty($_POST["usertype"])
		|| !isset($_POST["email"]) || empty($_POST["email"])
		||!isset($_POST["mobilephone"]) || empty($_POST["mobilephone"]) ) {
		echo "参数错误，用户信息填写不全";
		return;
	}else{
	$pdo=new PdoMySQL();
	$sql="UPDATE projector SET username='{$username}',password='{$password}',email='{$email}',mobilephone='{$mobilephone}' WHERE id={$id};";
	$stmt=$pdo->execute($sql);
	if($stmt==1){
		$result="信息更新成功";
	}else{
		$result="请修改信息，再提交";
		}
	}
	echo $result;
}
